package com.github.easyms.common.exception;

import com.github.easyms.common.constant.EasymsServiceStatus;

/**
 * @author Leo.Liao
 * Easyms系统业务异常
 * @date 2020-04-09 00:04:16
 */
public class EasymsException extends RuntimeException{

    private Integer code;
    private String message;
    private Object[] args;

    /**
     * 常规异常消息构造
     * @param message
     */
    public EasymsException(String message) {
        this.message = message;
    }

    /**
     * 【异常代码】&【异常消息】构造
     * @param code
     * @param message
     */
    public EasymsException(Integer code, String message) {
        this.message = message;
        this.code = code;
    }

    /**
     * 【异常代码】&【异常消息】&【I18N资源占位符数据】构造
     * @param code
     * @param message
     * @param objects
     */
    public EasymsException(Integer code, String message, Object... objects) {
        this.message = message;
        this.code = code;
        this.args = objects.clone();
    }

    /**
     * 【Easyms系统异常枚举】&【&I18N资源占位符数据】构造
     * @param easymsServiceStatus
     * @param objects
     */
    public EasymsException(EasymsServiceStatus easymsServiceStatus, Object... objects) {
        this.message = easymsServiceStatus.getMsgCode();
        this.code = easymsServiceStatus.code();
        this.args = objects.clone();
    }

    public EasymsException(EasymsServiceStatus easymsServiceStatus) {
        this.message = easymsServiceStatus.getMsgCode();
        this.code = easymsServiceStatus.code();
    }

    @Override
    public String getMessage() {
        return message;
    }

    public Integer getCode() {
        return code;
    }

    public Object[] getArgs() {
        return args;
    }

}
